﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace KUMC.Neurology.SomatoTopo
{
    public partial class FormSubFilt : Form
    {
        private string[] m_Param = null;
        private Label[] m_Label = null;
        private TextBox[] m_Textbox = null;
        private string[] m_Return = null;

        private const int TB_HEIGHT = 21;
        private const int TB_WIDTH = 240;
        private const int MARGIN = 5;
        private const int LB_HEIGHT = 21;
        private const int LB_WIDTH = 150;

        public FormSubFilt()
        {
            InitializeComponent();
        }
        public FormSubFilt(string[] param)
            : this()
        {
            m_Param = param;
        }

        public int[] DistOption
        {
            get
            {
                int[] ret = new int[m_Return.Length];
                for (int i=0; i<m_Return.Length; i++)
                {
                    ret[i] = int.Parse(m_Return[i]);
                }

                return ret;
            }

        }
        public string[] InputData
        {
            get
            {
                return m_Return;
            }
        }
        private void DistOptionInputForm_Load(object sender, EventArgs e)
        {
            InitControls();
        }
        private void OK_Click(object sender, EventArgs e)
        {
            m_Return = new string[m_Param.Length];
            for (int i = 0; i < m_Param.Length; i++)
            {
                m_Return[i] = m_Textbox[i].Text;
            }
        }

        private void InitControls()
        {
            int n = m_Param.Length;
            int formWidth = (MARGIN * 5) + LB_WIDTH + MARGIN + TB_WIDTH + (MARGIN * 5);
            int formHeight = (MARGIN * 10) + (n * TB_HEIGHT) + (n * MARGIN) + TB_HEIGHT + (MARGIN * 10);

            this.Size = new Size(formWidth, formHeight);

            m_Label = new Label[n];
            m_Textbox = new TextBox[n];

            for (int i = 0; i < n; i++)
            {
                m_Label[i] = new Label();
                m_Label[i].Size = new Size(LB_WIDTH, LB_HEIGHT);
                m_Label[i].Location = new Point(MARGIN, (MARGIN + LB_HEIGHT) * (i + 1));
                m_Label[i].Text = m_Param[i];
                m_Label[i].TextAlign = ContentAlignment.MiddleCenter;

                m_Textbox[i] = new TextBox();
                m_Textbox[i].Size = new Size(TB_WIDTH, TB_HEIGHT);
                m_Textbox[i].Location = new Point(MARGIN + LB_WIDTH + MARGIN, (MARGIN + TB_HEIGHT) * (i + 1));
            }

            BT_OK.Location = new Point(m_Textbox[n - 1].Location.X, m_Textbox[n - 1].Location.Y + TB_HEIGHT + MARGIN);
            BT_REMOVE.Location = new Point(m_Textbox[n - 1].Location.X + BT_OK.Width, m_Textbox[n - 1].Location.Y + TB_HEIGHT + MARGIN);
            BT_CANCEL.Location = new Point(m_Textbox[n - 1].Location.X + BT_OK.Width + BT_REMOVE.Width, m_Textbox[n - 1].Location.Y + TB_HEIGHT + MARGIN);
            Controls.AddRange(m_Label);
            Controls.AddRange(m_Textbox);
        }

    }
}
